package com.example.forum.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

import java.util.ArrayList;

/**
 * Created with IntelliJ IDEA.
 * Description: Swagger配置类
 * User: liuLi
 * Date: 2024-08-10
 * Time: 20:08
 */

// 配置类
@Configuration
// 开启Springfox-Swagger
public class SwaggerConfig {
    /**
     * Springfox-Swagger基本配置
     * @return
     */

        @Bean
        public Docket api() {
            return new Docket(DocumentationType.SWAGGER_2)
                    .apiInfo(apiInfo())
                    .select()
                    .apis(RequestHandlerSelectors.basePackage("com.example.forum.controller"))
                    .paths(PathSelectors.any())
                    .build();
        }

        private ApiInfo apiInfo() {
            return new ApiInfo(
                    "“技术汇”论坛系统API",
                    "该前后端分离的论坛系统API接口测试文档",
                    "1.0",
                    "Terms of Service",
                    new Contact("LiuLi", "https://blog.csdn.net/m0_60462557?spm=1000.2115.3001.5343", "2811209158@qq.com"),
                    "License of API",
                    "https://blog.csdn.net/m0_60462557?spm=1000.2115.3001.5343",
                    new ArrayList<>()
            );
        }
    }